import { PORT1 } from "@/api/config/servicePort";

import http from "@/api";

import { MerakXTableQuery } from "@/components/MerakXTable";

// 枚举路径
export const enum Path {
  // 员工管理
  personnel = "/personnel/personnel",
  orgs = "/personnel/orgs", //公司、部门管理
  orgsStations = "/personnel/org-titles", //岗位管理
  officeLocation = "/personnel/office-location", //办公地点
  goodsImport = "/goods-archive/goods-import", //商品导入
  markCompany = "/km/import-company", // 电子标签-进口公司
  markFees = "/km/markings-payment", // 电子标签-标签费用
  markImport = "/km/import" //标签导入
}

// 获取表头数据
export const getTableColumns = (path: string, queueId?: string) =>
  http.post<MerakXTableQuery.Columns>(`${PORT1}${path}/field`, {}, { queueId, loading: false });

// 获取表格数据
export const getTableData = (path: string, data: Record<string, any>, queueId?: string) =>
  http.post<{ table_data: MerakXTableQuery.Records; [k: string]: any }>(
    `${PORT1}${path}/list`,
    { ...data, sort: undefined },
    { params: { sort: data.sort }, queueId, loading: false }
  );

// 保存表格个性化设置
export const saveTableConfig = (payload: any, queueId?: string) =>
  http.post(`${PORT1}/api/save-table-config`, { ...payload }, { queueId, loading: false });

//导出表格
export const exportTableApi = params => http.post(`${PORT1}/task-list/export`, params, { loading: false });
